package com.example.serverdemo.netty.initializer;

import com.example.serverdemo.netty.device_tcp_server.handler.DeviceHandler;
import io.netty.channel.ChannelInitializer;
import io.netty.channel.socket.SocketChannel;
import io.netty.handler.timeout.IdleStateHandler;
import org.springframework.stereotype.Component;

import java.util.concurrent.TimeUnit;

@Component
public class DeviceCommunicationInitializer extends ChannelInitializer<SocketChannel> {
    @Override
    protected void initChannel(SocketChannel socketChannel) throws Exception {
        socketChannel.pipeline().addLast("idleCheckHandler",new IdleStateHandler(5,0,0, TimeUnit.SECONDS));
        socketChannel.pipeline().addLast(new DeviceHandler());
    }
}
